import 'package:first_flutter_demo/utils/HexColor.dart';
import 'package:flutter/material.dart';
import 'tabs/Home.dart';
import 'tabs/Service.dart';
import 'tabs/Activity.dart';
import 'tabs/Store.dart';
import 'tabs/Mine.dart';

class Tabs extends StatefulWidget {
  const Tabs({Key? key}) : super(key: key);

  @override
  _TabsState createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  int currentIndex = 0;
  final List _pageList = [
    HomePage(),
    ServicePage(),
    ActivityPage(),
    StorePage(),
    MinePage()
  ];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: _pageList[currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          currentIndex: currentIndex,
          selectedItemColor: HexColor("#E72F41"),
          unselectedItemColor: HexColor("#626C78"),
          selectedFontSize: 12,
          unselectedFontSize: 12,
          onTap: (int index) {
            setState(() {
              currentIndex = index;
            });
          },
          items: [
            BottomNavigationBarItem(
              icon: Image.asset(
                "assets/images/home_unselected.png",
                height: 22,
                width: 22,
              ),
              activeIcon: Image.asset(
                "assets/images/home_selected.png",
                height: 22,
                width: 22,
              ),
              label: "首页",
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                "assets/images/service_unselected.png",
                height: 22,
                width: 22,
              ),
              activeIcon: Image.asset(
                "assets/images/service_selected.png",
                height: 22,
                width: 22,
              ),
              label: "服务",
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                "assets/images/activity_unselected.png",
                height: 22,
                width: 22,
              ),
              activeIcon: Image.asset(
                "assets/images/activity_selected.png",
                height: 22,
                width: 22,
              ),
              label: "活动",
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                "assets/images/shops_unselected.png",
                height: 22,
                width: 22,
              ),
              activeIcon: Image.asset(
                "assets/images/shops_selected.png",
                height: 22,
                width: 22,
              ),
              label: "商家",
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                "assets/images/me_unselected.png",
                height: 22,
                width: 22,
              ),
              activeIcon: Image.asset(
                "assets/images/me_selected.png",
                height: 22,
                width: 22,
              ),
              label: "我的",
            ),
          ],
        ),
      ),
    );
  }
}
